package com.gxa.mobile.controller;

import com.gxa.service.OrderListRpcDto;
import com.gxa.core.result.Result;
import com.gxa.core.result.ResultUtils;

import com.gxa.mobile.service.OrderListService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：lizhijun
 * @Package：{PROJECT_NAME}
 * @name：{DATE} {NAME}
 */
@RestController
@Slf4j
@RequestMapping("/portal/TakeAway")
public class DeskOrderController {

    @Autowired
    private OrderListService orderListService;

   //点击结算按钮后，将订单加入到数据库里
    @PostMapping("/addOrder")
    public Result addOrder(OrderListRpcDto orderListRpcDto) {
        log.info("添加订单");
        //远程调用
        return ResultUtils.buildSuccess( this.orderListService.addOrderList(orderListRpcDto));
    }
    //用户登录后，查询他的所有订单
    @GetMapping("/showTakeWayOrder")
    public Result showOrderById(String orderType ) {
            return ResultUtils.buildSuccess(this.orderListService.findAllOrderList(orderType));
    }
    //根据订单号查看订单详情
    @GetMapping("/showOrderById")
    public Result showOrderByOrderId(String orderId) {
        return ResultUtils.buildSuccess(this.orderListService.getOrderList(orderId));
    }

    @PostMapping("/transfer")
    public Result updateOrder(OrderListRpcDto orderListRpcDto){
   log.info("修改订单{}",orderListRpcDto);
        return ResultUtils.buildSuccess(orderListService.updateOrder(orderListRpcDto));
    }


}
